<?php
namespace Home\Controller;
use Think\Controller;
class UseController extends CommonController {
    public function index(){

    	$id = I('get.id');

    	$user = M('user')->where(array('id'=>$id))->select();

    	$user = current($user);

    	$this->assign('user',$user);

    	$question = M('question')->select();

        // var_dump($question);

    	$this->assign('question',$question);

        $sql = "select t1.*,t2.title from answer t1 inner join question t2 on t1.qid=t2.id where t1.uid='{$id}'";
        
        $answer = M()->query($sql);

        $this->assign('answer',$answer);

        $this->assign('title',$user['nickname'].个人中心);

        $this->display();
    }

    public function checkname()
    {
       $nickname = I('get.nickname');

       $res = M('user')->where(array('nickname'=>$nickname))->find();

       // var_dump($res);exit;

       $url = U('home/use/index',array('id'=>$res['id']));

       // var_dump($url);

       header("Location:".$url);


    }
}